package com.gxa.saas.portal.config;

import org.springframework.context.annotation.Configuration;

import java.io.FileWriter;
import java.io.IOException;

/**
 * @Auther: pengxtao
 * @Date: 2022/7/25下午10:01
 */
@Configuration
public class AlipayConfig {
    // ↓↓↓↓↓↓↓↓↓↓请在这里配置您的基本信息↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

    // 应用ID,您的APPID，收款账号既是您的APPID对应支付宝账号
    public static String app_id = "2021000119673977";

    // 商户私钥，您的PKCS8格式RSA2私钥
    public static String merchant_private_key = "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQChffc7i6Ag4j2HFLPPMLTzLK0i4pUL0zl9hKYNudw3yd++grv3U2b6xjHfEJgbjF9wADn0bdI2A43f+w49EBNB9xrRF4t8cCzkqRuA+tjNJR5vklyNHSmX90E3qQjPr5eNDMcIaw0RNFXmaL/RWZ8gPl2zgB1Z4F+jXWzKDNYFqhqJAmXDYkyNca96slIGoWRAqKX2E/9ETBiysVgmUWgW93hTHaO4XdNl+Wlkz+FhrzLnFuh/4B4QnUGuprh4Ak5gq5G2OGrTh5FCYk31aKoHePQrlrEQQP63Sms+BOoBoJUKTQVuX0Px6Owk3mFothXagHNBgZHS6FjonYwSf0kHAgMBAAECggEAWgjan84Wdn7sArWeEfN7zt+nn31nz3Hx6XLdCWYHyuq33YURurA7B7Eb+NtNkn5ObykRJp9bxVVx8eAMbiraMbrMrqpL0BLSVKGbfetcl/ML5vRYuSv7Foh5Scjp6rBg8/idtqnIXUEqaw0XdGZc+yMKJptUwdkAORpLHtLNN9ZdjTQ8Zs7ujosz/40SZ8frcuE1IeutcsKgzlp2kQGJ0VwkLWKB+Y5q7TWZP9lvoyQxFw3m8vX6JZF6zjWGr3DYJNc9rohwPMvuO3Mrc9pGmr+k8R9YitGSXR3fiflCABvEbRksnABM3wjgNY9vYa0oldJ91fEy57SfVde1SUtqgQKBgQDUDwOy9fxX8VVnB4r2xZq+bB8OjMfTzQOWosMwKz3O/cOM+O2OlVLM15+SS81tTNr8YV5aOz2bW2eZTXVxPAVq3ubbR25mUqdocMAy547MIzZiWIwLzRIr7xR52pxlWEKBsKl9aALtMpFu13KVvEqhNPeknLo9EBGENpZEtcvYYQKBgQDC9JECSiiyKiyMTv5B18JswB2/sLN9myChcay86aE/bJfj1KtCd8aZAaw0TP4HbAgoJoZjzaGtEl6O+gOMVrasZZCflFe1r82nw+elGePToIjN0mUdVkgUhn0t8FDERSncMI5YlVAgqaM/fSa0suA4+SQra1/7DwtNMDTawX16ZwKBgQCGWZDdZA1g5ixWXygCmkUk2bl/bV/4502btTj2np7FMm8fNGLFUAOqdf3KIS5gTi37cfDmN9wbPnjPXozGleFUyS33xTTDrSAVAkIyvhPxb2m4OyNXIrCdlxYg8YjeiGFyayumoSwhfUU4tVUKWsXphnZTG1y+7Rw76J2hoJAqYQKBgQCFcZgMZCyE/18szyk0cnYvsDTssAu8L0HfoAqn6Jcp7a/uD/UF8yxqMP3pcsXy2JygtvYIPImtCMTWwwVIu1YgnQioYobC40o2yl614QnUIq9hiuEReqyt9/yZRERUhC8J++aDdfi50sPeQlELIOFfvhFm8wFovLx0okmbbxPvgwKBgQCJZ5EoSpBLuri2ebB2eeomIXO5+5pcgKng06NtPN4Eilczw/lWs44o/FD+elfzaV84Z4X9H8eCOZfxruvWJNjoYGmWC98vomuEa7ZUSl9ShyIT1ExXLv/uLEl7txy6UhBiaQw6DgE+DebuNCKKA4YkP1WWI4wFbHLwle8KYLxmcg==";

    // 支付宝公钥,查看地址：https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
    public static String alipay_public_key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjiTvnLVjmfJd0ZFMbLszkeSK+2ObtaFMmIyiWWoHxZBQthZK99c3bp9j9Kz5uE9U5BmosLo3AIa6b/PMu54p2mo2jNio2uQTuAjuBGLcQCurkbXHh1ltPmWEIlSniZESOKXqFhexo22HutfPuNY4bFQt/NRUzzMY3lSFd0K0iQkxezz66kNW2Yc8dfEM5HOAVumRiyWu4elf80ehwar3NFgpzjE8uDu4/8FbklvpBU/7eucsymZP8P0mUBb2BvtZ7GzqrKZ1lZyLIky9BLQe+pDtjPSLmpDgKUq0tnIskMi0FRd3wVlSkn/A9JuGUO+XYmyBveLdL+iqoiRRgUVswwIDAQAB";

    // 服务器异步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问

    // 这里需要配置支付宝回调的后端路径，必须要外网可以访问
    public static String notify_url = "http://117.50.188.67:8081/payAli";

    // 页面跳转同步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问

    // TODO 这里需要配置支付宝回调的前端路径，必须要外网可以访问
    public static String return_url = "http://localhost:8080/payccess";

    // 签名方式
    public static String sign_type = "RSA2";

    // 字符编码格式
    public static String charset = "GBK";

    // 支付宝网关
    public static String gatewayUrl = "https://openapi.alipaydev.com/gateway.do";

    // 日志路径
    public static String log_path = "/Users/agionlost";

    // ↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑

    /**
     * 写日志，方便测试（看网站需求，也可以改成把记录存入数据库）
     *
     * @param sWord 要写入日志里的文本内容
     */
    public static void logResult(String sWord) {
        FileWriter writer = null;
        try {
            writer = new FileWriter(log_path + "alipay_log_" + System.currentTimeMillis() + ".txt");
            writer.write(sWord);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}